//1������ gr_InstallPath �Ⱥź���Ĳ����ǲ����װ�ļ������ڵ���վĿ¼����������Ե�ַ��
//   һ�����վ�ĸ�Ŀ¼��ʼѰַ�������װ�ļ�һ��Ҫ������ָ��Ŀ¼�¡�
//2��Version �Ⱥź���Ĳ����ǲ����װ��İ汾�ţ�������°汾�����װ��Ӧ�ϴ��°�
//   �������װ�ļ�����վ��ӦĿ¼������������İ汾�š�
//3�������ϸ��Ϣ��ο������С�������(WEB����)->�ڷ�������������װ���
var gr_InstallPath = "/grinstall";
var gr_Version = "5,8,13,0220";

//����ע���Ϊ��������ע��ţ�������ʵ�ַΪlocalhostʱ����ȥ�����ñ�־
//����ע����������ע���û�����ע����滻���������ֵ
var gr_UserName = '����'; // '���˱�������������ע��';
var gr_SerialNo = '4DFB949E066NYS7W11L8KAT53SA177391Q9LZQ094WUT9C9J3813SX8PTQC4ALPB9UAQN6TMA55Q3BN8E5726Z5A839QAD9P6E76TKNK5';

//��������(IE or not)
var agent = navigator.userAgent.toLowerCase();
var isIE = (agent.indexOf("msie")>0)? true : false;

var gr_CodeBase;
gr_CodeBase = 'codebase="' + gr_InstallPath + '/grbsctl5.cab#Version=' + gr_Version + '"';
//if( isIE )
//    gr_CodeBase = 'codebase="' + gr_InstallPath + '/grbsctl5.cab#Version=' + gr_Version + '"';
//else
//    gr_CodeBase = ''; //TBD... 'codebase="' + gr_InstallPath + '/grbsctl5.xpi"';

//����������󣬱�������ǲ��ɼ�Ķ�����ϸ��鿴�����е� IGridppReport
//Name - ָ����������ID��������js���� document.getElementById("%Name%") ��ȡ�������
//EventParams - ָ������������Ҫ��Ӧ���¼����磺"<param name='OnInitialize' value=OnInitialize> <param name='OnProcessBegin' value=OnProcessBegin>"��ʽ������ָ������¼�
function CreateReport(PluginID, EventParams)
{
    var typeid;
    if( isIE )
        typeid = 'classid="clsid:25240C9A-6AA5-416c-8CDA-801BBAF03928" ';
    else
        typeid = 'type="application/x-grplugin-report" ';
    typeid += gr_CodeBase;
	document.write('<object id="' + PluginID + '" ' + typeid);
	document.write(' width="0" height="0" VIEWASTEXT>');
	if (EventParams != undefined)
	    document.write(EventParams);
	document.write('</object>');
	
	document.write('<script type="text/javascript">');
	    document.write(PluginID + '.Register("' + gr_UserName + '", "' + gr_SerialNo + '");');
	document.write('</script>');
}

//�ø��Ĳ�������ӡ��ʾ�������ϸ��鿴�����е� IGRPrintViewer
//PluginID - �����ID������ͨ�� var ReportViewer = document.getElementById("%PluginID%"); ����ķ�ʽ��ȡ������ñ���
//Width - �������ʾ��ȣ�"100%"Ϊ�����ʾ�����ȣ�"500"��ʾ500����Ļ���ص�
//Height - �������ʾ�߶ȣ�"100%"Ϊ�����ʾ����߶ȣ�"500"��ʾ500����Ļ���ص�
//ReportURL - ��ȡ����ģ���URL
//DataURL - ��ȡ������ݵ�URL
//AutoRun - ָ������ڴ���֮���Ƿ��Զ���ɲ�չ�ֱ���,ֵΪfalse��true
//ExParams - ָ�����Ĳ�����Բ���,����: "<param name="%ParamName%" value="%Value%">"����Ĳ���
function CreatePrintViewerEx2(PluginID, Width, Height, ReportURL, DataURL, AutoRun, ExParams)
{
    var typeid;
    if( isIE )
        typeid = 'classid="clsid:B7EF88E6-A0AD-4235-B418-6F07D8533A9F" ' + gr_CodeBase;
    else
        typeid = 'type="application/x-grplugin-printviewer"';
	document.write('<object id="' + PluginID + '" ' + typeid);
	document.write(' width="' + Width + '" height="' + Height + '">');
	document.write('<param name="ReportURL" value="' + ReportURL + '">');
	document.write('<param name="DataURL" value="' + DataURL + '">');
	document.write('<param name="AutoRun" value=' + AutoRun + '>');
	document.write('<param name="SerialNo" value="' + gr_SerialNo + '">');
	document.write('<param name="UserName" value="' + gr_UserName + '">');
	document.write(ExParams);
	document.write('</object>');
}

//�ø��Ĳ�������ӡ��ʾ�������ϸ��鿴�����е� IGRDisplayViewer
//PluginID - �����ID������ͨ�� var ReportViewer = document.getElementById("%PluginID%"); ����ķ�ʽ��ȡ������ñ���
//Width - �������ʾ��ȣ�"100%"Ϊ�����ʾ�����ȣ�"500"��ʾ500����Ļ���ص�
//Height - �������ʾ�߶ȣ�"100%"Ϊ�����ʾ����߶ȣ�"500"��ʾ500����Ļ���ص�
//ReportURL - ��ȡ����ģ���URL
//DataURL - ��ȡ������ݵ�URL
//AutoRun - ָ������ڴ���֮���Ƿ��Զ���ɲ�չ�ֱ���,ֵΪfalse��true
//ExParams - ָ�����Ĳ�����Բ���,����: "<param name="%ParamName%" value="%Value%">"����Ĳ���
function CreateDisplayViewerEx2(PluginID, Width, Height, ReportURL, DataURL, AutoRun, ExParams)
{
    var typeid;
    if( isIE )
        typeid = 'classid="clsid:CB45DFE5-6C35-4687-B790-FEC65D512859" ' + gr_CodeBase;
    else
        typeid = 'type="application/x-grplugin-displayviewer"';
	document.write('<object id="' + PluginID + '" ' + typeid);
	document.write(' width="' + Width + '" height="' + Height + '">');
	document.write('<param name="ReportURL" value="' + ReportURL + '">');
	document.write('<param name="DataURL" value="' + DataURL + '">');
	document.write('<param name="AutoRun" value=' + AutoRun + '>');
	document.write('<param name="SerialNo" value="' + gr_SerialNo + '">');
	document.write('<param name="UserName" value="' + gr_UserName + '">');
	document.write(ExParams);
	document.write('</object>');
}

//�ø��Ĳ������������������ϸ��鿴�����е� IGRDesigner
//Width - �������ʾ��ȣ�"100%"Ϊ�����ʾ�����ȣ�"500"��ʾ500����Ļ���ص�
//Height - �������ʾ�߶ȣ�"100%"Ϊ�����ʾ����߶ȣ�"500"��ʾ500����Ļ���ص�
//LoadReportURL - ��ȡ����ģ���URL������ʱ�Ӵ�URL���뱨��ģ����ݲ����ص���������
//SaveReportURL - ���汨��ģ���URL��������ƺ�Ľ����ݣ��ɴ�URL�ķ�����WEB����˽�����ģ��־ñ���
//DataURL - ��ȡ��������ʱ��ݵ�URL����������н����ӡ��ͼ���ѯ��ͼʱ�Ӵ�URL��ȡ�������
//ExParams - ָ�����Ĳ�����Բ���,����: "<param name="%ParamName%" value="%Value%">"����Ĳ���
function CreateDesignerEx(Width, Height, LoadReportURL, SaveReportURL, DataURL, ExParams)
{
    var typeid;
    if( isIE )
        typeid = 'classid="clsid:3C19F439-B64D-4dfb-A96A-661FE70EA04D" ' + gr_CodeBase;
    else
        typeid = 'type="application/x-grplugin-designer"';


	document.write('<object id="ReportDesigner" ' + typeid);
	document.write(' width="' + Width + '" height="' + Height + '">');
	document.write('<param name="LoadReportURL" value="' + LoadReportURL + '">');
	document.write('<param name="SaveReportURL" value="' + SaveReportURL + '">');
	document.write('<param name="DataURL" value="' + DataURL + '">');
	document.write('<param name="SerialNo" value="' + gr_SerialNo + '">');
	document.write('<param name="UserName" value="' + gr_UserName + '">');
	document.write(ExParams);
	document.write('</object>');
}

function CreatePrintViewerEx(Width, Height, ReportURL, DataURL, AutoRun, ExParams)
{
    CreatePrintViewerEx2("ReportViewer", Width, Height, ReportURL, DataURL, AutoRun, ExParams)
}

function CreateDisplayViewerEx(Width, Height, ReportURL, DataURL, AutoRun, ExParams)
{
    CreateDisplayViewerEx2("ReportViewer", Width, Height, ReportURL, DataURL, AutoRun, ExParams)
}

function CreatePrintViewer(ReportURL, DataURL)
{
    CreatePrintViewerEx("100%", "100%", ReportURL, DataURL, true, "");
}

function CreateDisplayViewer(ReportURL, DataURL)
{
    CreateDisplayViewerEx("100%", "100%", ReportURL, DataURL, true, "");
}

function CreateDesigner(LoadReportURL, SaveReportURL, DataURL)
{
    CreateDesignerEx("100%", "100%", LoadReportURL, SaveReportURL, DataURL, "");
}